package com.ifgi.sitcom.campusmapperNDrawer.adapters;



import java.util.ArrayList;

import com.gamificationlibrary.model.leaderboard.Leaderboard;
import com.gamificationlibrary.model.*;
import com.ifgi.sitcom.campusmapperNDrawer.R;



import com.ifgi.sitcom.campusmapperNDrawer.controllers.CampusMapperApplication;
import com.ifgi.sitcom.campusmapperNDrawer.gamedata.PlayerAdapter;
import com.ifgi.sitcom.campusmapperNDrawer.indoordata.FloorPlan;
import com.ifgi.sitcom.campusmapperNDrawer.outdoordata.Building;

import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ListViewOwnersAdapter extends ArrayAdapter<Ownership<FloorPlan>>{
	
	private final Context context;
	private ArrayList<Ownership<FloorPlan>> floorsOwnership;
   
  public ListViewOwnersAdapter(Context context,ArrayList<Ownership<FloorPlan>> floorsOwnership) {

        super(context, R.layout.dialog_owners,floorsOwnership);
    
        this.context = context;
        this.floorsOwnership=floorsOwnership;
    }

 
	@Override
    public View getView(int position, View convertView, ViewGroup parent) {

        // 1. Create inflater
        LayoutInflater inflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        // 2. Get rowView from inflater

        View rowView = null;
        rowView = inflater.inflate(R.layout.item_owner, null, true);
        rowView.setEnabled(false);
		rowView.setOnClickListener(null);
	
        // 3. Get all views from the rowView
        TextView titleView = (TextView) rowView.findViewById(R.id.text_buildingsOwners);
        ImageView imgView = (ImageView) rowView.findViewById(R.id.iconOwner);
        TextView usernameView = (TextView) rowView.findViewById(R.id.textview_usernameOwner);
        usernameView.setTypeface(null, Typeface.BOLD);
        TextView descriptionView = (TextView) rowView.findViewById(R.id.texxtview_scoreOwner);
        
        Player lRow=null;
        lRow=floorsOwnership.get(position).getP();
        	
    	titleView.setText("Floorplan number "+floorsOwnership.get(position).getT().getFloorNumber()+" owner");
    	usernameView.setText(((PlayerAdapter) lRow).getUsername());
    	descriptionView.setText(String.valueOf(floorsOwnership.get(position).getS().getValue())+" points");
    	imgView.setImageBitmap(((PlayerAdapter) lRow).getPicture().bitmap);
 
         // 5. return rowView
        return rowView;
    }
      

}
